var superagent=require('superagent')
var async=require('async')
var cheerio=require('cheerio')
var eventproxy=require('eventproxy')
var ep=new eventproxy()
var mongoose = require('mongoose')
var mongourl = 'mongodb://127.0.0.1:27017'





mongoose.Promise = global.Promise; 
mongoose.connect(mongourl,{useMongoClient:true}); 
var Schema = mongoose.Schema;  
//骨架模版  
const movieSchema = new Schema({  
    lng:String,
    lat:String,
})  
//模型  
const Movie = mongoose.model('chinaPoint', movieSchema);  
//存储数据  


superagent.get('http://api.map.baidu.com/api?v=2.0&ak=1XjLLEhZhQNUzd93EjU5nOGQ')
    .end(function(err,res){
        if(err)
            console.error('错误')
        else{
            console.log(res)
        }
    })





var dianshu = new BMap.Boundary();  
dianshu.get('中国', function (rs) {       //获取行政区域  
    var aaa=rs.boundaries[0] 
    var poi=aaa.split(';')
    for(var i=0;i<poi.length;i++){
        const moive = new Movie({
            lng:poi[i][0],
            lat:poi[i][1]
        })  
        //保存数据库  
        moive.save(function(err) {
            if (err) {  
                console.log('保存失败')  
                return;  
            }              
        }) 
    }
}); 









